//
//  NSString+Handle.m
//  TourguideAndCar
//
//  Created by zgy on 15/3/3.
//  Copyright (c) 2015年 livebytouch. All rights reserved.
//

#import "NSString+Handle.h"

@implementation NSString (Handle)

/**
 *  字符串是否为空
 */
+(BOOL)stringIsNull:(NSString*)string
{
    if (string == nil || string == NULL)
    {
        return YES;
    }
    if ([string isKindOfClass:[NSNull class]])
    {
        return YES;
    }
    // 去掉前后空格，判断length是否为0
    if ([[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length] == 0)
    {
        return YES;
    }
    if ([string isEqualToString:@"(null)"] || [string isEqualToString:@"null"])
    {
        return YES;
    }
    return NO;
    
}

+ (NSString *)timeFormatted:(long)totalSeconds
{
    long absSecond = labs(totalSeconds);
    long minutes = (absSecond / 60) % 60;
    long hours = absSecond / 3600;
    if (hours > 72) {
        return @"大于3天";
    }
    return [NSString stringWithFormat:@"%ld小时%ld分钟",hours, minutes];
}

+ (NSString *)attributeTimeFormatted:(long)totalSeconds
{
    long absSecond = labs(totalSeconds);
    long minutes = (absSecond / 60) % 60;
    long hours = absSecond / 3600;
    if (hours > 72) {
        return @"大于3天";
    }
    return [NSString stringWithFormat:@"%ld>%ld",hours, minutes];
}
@end
